
observed.exectime <- array(0, c(my.nb_obs))
for (i in 1:my.nb_obs) observed.exectime[i] <- sum(my.data[i,])
ECDF <- ecdf(observed.exectime)
observed.ecdf <- array(0, c(my.nb_points))

index <- 1  
my.steps <- seq(min(observed.exectime), my.max.range * max(observed.exectime), length.out = my.nb_points)  
for (i in my.steps) {
  observed.ecdf[index] <- ECDF(i)
  index <- index + 1
}

print("now processing V-AEP")

my.aep.frame <- as.aep.frame(data=my.data, iteration=my.nb_iterations, bandwidth=my.bandwidth)

estimated.ecdf <- array(0, c(my.nb_points))
index <- 1
for (i in my.steps) {
  result <- AEP.f(frame=my.aep.frame, vsum=i)
  #result <- AEP.d(data=my.data, iteration=my.nb_iterations, bandwidth=my.bandwidth, vsum=i)
  print(result)
  estimated.ecdf[index] <- result@prob
  index <- index + 1
}

for (i in seq(length(estimated.ecdf), 1, -1)) {
  if (estimated.ecdf[i] > 1) estimated.ecdf[i] <- 1
  if (i < length(estimated.ecdf) & estimated.ecdf[i] > estimated.ecdf[i+1]) estimated.ecdf[i] <- estimated.ecdf[i+1]
}

observed.Recdf = 1 - observed.ecdf
estimated.Recdf = 1 - estimated.ecdf

estimated.q95 <- find_quantile(x=my.steps, y=estimated.Recdf, q=0.95, precision=0.001)
estimated.q99 <- find_quantile(x=my.steps, y=estimated.Recdf, q=0.99, precision=0.001)
observed.q95 <- find_quantile(x=my.steps, y=observed.Recdf, q=0.95, precision=0.001)
observed.q99 <- find_quantile(x=my.steps, y=observed.Recdf, q=0.99, precision=0.001)
observed.q100 <- find_quantile(x=my.steps, y=observed.Recdf, q=1, precision=0.001)
